package com.shuqi.database.dao.impl;

import java.sql.SQLException;

import net.sqlcipher.database.SQLiteDatabase;
import android.content.Context;

import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import com.shuqi.database.dao.DBConfig;
import com.shuqi.database.dao.OrmBaseDatabaseHelper;
import com.shuqi.database.model.UserInfo;


public class AccountDatabaseHelper extends OrmBaseDatabaseHelper {

    private static AccountDatabaseHelper mHelper = null;

    public static synchronized AccountDatabaseHelper getHelper(Context context) {
        if (mHelper == null) {
            mHelper = new AccountDatabaseHelper(context);
        }
        return mHelper;
    }

    private AccountDatabaseHelper(Context context) {
        super(context, DBConfig.ACCOUNT_DB_NAME, null, DBConfig.ACCOUNT_DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase arg0, ConnectionSource arg1) {
        try {
            TableUtils.createTableIfNotExists(arg1, UserInfo.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onUpgrade(SQLiteDatabase arg0, ConnectionSource arg1, int arg2, int arg3) {}
}
